package com.yc.mvc.web;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
public class IndexAction2 {

    //@RequestMapping(path = "rm1", method = RequestMethod.POST)
    // 效果同上
    @PostMapping("rm1")
    //@GetMapping("rm1")
    public String rm1() {
        return "rm1";
    }

    // 127.0.0.1/xxx/rm2?a=1&b=1&c=1
    @GetMapping(path = "rm2",params = { "a", "b=1", "c!=2" , "!d" })
    //@GetMapping("rm2")
    public String rm2() {
        return "rm2";
    }

    @GetMapping(path = "rm3",headers = {"Accept","Host=127.0.0.1"})
    //@GetMapping("rm3")
    public String rm3() {
        return "rm3";
    }

    @PostMapping(path = "rm4", consumes = MediaType.TEXT_PLAIN_VALUE)
    public String rm4() {
        return "rm4";
    }

    // 限定文件上传
    @PostMapping(path = "rm5", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String rm5() {
        return "rm5";
    }

    // 中文乱码
    @GetMapping(path = "rm6")
    public String rm6() {
        return "rm6 ==> 中文数据";
    }

    @GetMapping(path = "rm7", produces = "text/html;charset=utf-8")
    public String rm7() {
        return "rm7 ==> 中文数据";
    }

}
